﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Szabalyrendszer.Adatok;
using Szabalyrendszer;

namespace Szimulator
{
    public partial class ErekjeIdomagia : UserControl
    {
        public ErekjeIdomagia()
        {
            InitializeComponent();
            foreach (var item in Enum.GetValues(typeof(IdomagiaTipus)).Cast<IdomagiaTipus>())
            {
                idomagiTipus.Items.Add(item.ToString());
            }
        }

        public List<Idomagia> Idomagiak { get; set; }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            Parent.Controls.Remove(this);
        }

        private void idomagiTipus_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (var idomagia in Idomagiak.Where(i => i.Tipus.ToString() == idomagiTipus.SelectedItem.ToString()))
            {
                idomagiaErosseg.Items.Add(idomagia.Idotartam);
            }            
        }

        private void idomagiaErosseg_SelectedIndexChanged(object sender, EventArgs e)
        {
            mannaKoltseg.Text = Idomagiak.First(i => i.Tipus.ToString() == idomagiTipus.SelectedItem.ToString() && i.Idotartam == (int)idomagiaErosseg.SelectedItem).MannaPont.ToString() + " Mp";
        }
    }
}
